package io.itit.ecp.admin.provide.selected;

import io.itit.ecp.admin.common.enums.IEnergyTypeEnums;
import io.itit.grass.common.provide.action.resp.SelectedResp;
import io.itit.grass.common.server.selected.ISelected;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 能源类型因子单位选择器
 */
@Component
public class EnergyTypeFactorUnitSelected implements ISelected<SelectedResp> {

    public static final String CODE = "EnergyTypeFactorUnitSelected";

    @Override
    public String code() {
        return CODE;
    }

    @Override
    public List<SelectedResp> get(String param) {
        return Arrays.stream(IEnergyTypeEnums.Type.values())
                .map(t -> SelectedResp.builder().label(t.getFactorUnit()).value(t.getType()).build())
                .collect(Collectors.toList());
    }
}
